/*
题目链接 : https://leetcode.cn/problems/maximum-unique-subarray-sum-after-deletion/description/
*/

//题解代码:
class Solution {
public:

    int maxSum(vector<int>& nums) {
        unordered_map<int,int> ump;
        int ans = 0,n = nums.size();
        int mx = INT_MIN;
        for(int i=0;i<n;++i){
            mx = max(mx,nums[i]);
            if(nums[i]>=0){
                if(ump.count(nums[i]))continue;
                ans += nums[i];
                ump[nums[i]] = 1;
            }  
        }
        return mx<0 ? mx : ans;
        
    }
};
